using System.Collections;
using System.IO;
using UnityEngine;

public class LevelManager {
    private static LevelManager instance;
    private int curLevel = 1;

    private string[] allToies = {};


    private delegate void LoadAllToiesComplete(IConfigData data);

    public void Init() {
        ResourcesMaanger.Instance.LoadConfig("Config/allToy.json",EConfigType.ALL_TOY,LoadToiesOver);
    }

    void LoadToiesOver(IConfigData data) {
        AllToyConfig datas = (AllToyConfig)data;
        Debug.Log("datas is " + datas);
        string[] allData = datas.levels;
        allToies = allData;

    }

/// <summary>
/// 大于300关的时候调用该方法 直接使用所有的玩具 打乱顺序再主游戏里面会打乱的
/// </summary>
/// <returns></returns>
    public string[] GetLevelData() {
        if(allToies.Length == 0) return allToies; 
        return allToies;
    }

    public int CurLevel {
        set {
            curLevel = value;
            GameManager.Instance().game.UpdatePlayerData(null,curLevel);
        }
        get {
            return curLevel;
        }
    }

    public static LevelManager Instance {
        get {
            instance ??= new LevelManager();
            return instance;
        }
    }
}